//多线程练习

use std::sync::{mpsc, Arc};
use std::thread;
use std::time::Duration;

fn main() {
    run(10);
}

fn run(number: u32) {
    let (tx, rx) = mpsc::channel(); //通信数据
    for i in 0..number {
        let tx = tx.clone();
        thread::spawn(move || {
            let _ = tx.send(i.to_string());
            thread::sleep(Duration::from_millis(1));
        });
        let msg = rx.recv().unwrap();
        println!("message is {}", msg);
    }
}